package com.soft.line.util.encrypt;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;

/**
 * AES方式加密解密数据工具类
 *
 * @author 86185
 * @date 2020/5/9 16:55
 */
public final class AesEncryptUtil extends BaseEncrypt {

    public static String encrypt(String content, String key) {
        return encrypt(content, key.getBytes(DEFAULT_CHARSET));
    }

    public static String encrypt(String content, byte[] key) {
        key = concat(key);
        AES aes = SecureUtil.aes(key);
        return encrypt(aes, content);
    }

    public static String decrypt(String encrypt, String key) {
        return decrypt(encrypt, key.getBytes(DEFAULT_CHARSET));
    }

    public static String decrypt(String encrypt, byte[] key) {
        key = concat(key);
        AES aes = SecureUtil.aes(key);
        return decrypt(aes, encrypt);
    }

}
